package com.situ.web.service;

import java.util.List;

import com.situ.web.dao.TeacherDao;
import com.situ.web.entity.PageInfo;
import com.situ.web.entity.Teacher;

public class TeacherService {
	private TeacherDao teacherDao = new TeacherDao();

	public PageInfo findByPage(int pageNo, int pageSize) {
		PageInfo pageInfo = new PageInfo();
		pageInfo.setPageNo(pageNo);
		pageInfo.setPageSize(pageSize);
		
		// totalPage
		int count = teacherDao.getTotalCount();
		int totalPage = (int)Math.ceil((double)count / pageSize);
		pageInfo.setTotalPage(totalPage);
		
		// list
		int offset = (pageNo - 1) * pageSize;
		// limit offset,pageSize
		List<Teacher> list = teacherDao.findByPage(offset, pageSize);
		pageInfo.setList(list);
		
		return pageInfo;
	}

	
	
}
